<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="nav">
        <a href="#/news">新闻</a>
        <a href="#/hao">hao123</a>
        <a href="#/map">地图</a>
    </div>
    <div id="content"></div>
    <script>
        window.addEventListener("hashchange", function(e) {

            console.log(location);
            switch (location.hash) {
                case "#/news":
                    document.getElementById("content").innerHTML = "新闻";
                    break;
                case "#/hao":
                    document.getElementById("content").innerHTML = "好123";
                    break;
                case "#/map":
                    document.getElementById("content").innerHTML = "地图"
                    break;
            }
        })
    </script>
</body>

</html>